﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CSF.Utility.Security;

namespace CSF.Service.Accounts.Client
{
    public class AccountsCenterHelper
    {
        public static string BuildLogOnUrl(string toUrl)
        {
            string result = null;

            AccountServiceConfigSection config = AccountServiceConfigManager.Load();
            //result = config.AccountCenterBaseUrl;
            if (result.Last() != '/')
                result += '/';
            result += "Account/LogOn";

            string timestamp = AppCodec.GetTimeStamp();
            result += "?appCode=" + AppCodec.Encode(config.AppCode, timestamp);
            result += "&timeStamp=" + timestamp;
            result += "&toUrl=" + toUrl;

            return result;
        }

        public static string BuildMyAccountUrl(string sessionId, string toUrl)
        {
            string result = null;

            AccountServiceConfigSection config = AccountServiceConfigManager.Load();
            //result = config.AccountCenterBaseUrl;
            if (result.Last() != '/')
                result += '/';
            result += "Account/MyAccount";

            result += "?SessionId=" + sessionId;
            result += "&toUrl=" + toUrl;

            return result;
        }
    }
}
